package edu.ustb.mis.dm.simpleTest;

import java.util.HashSet;
import java.util.List;
import java.util.Set;
import edu.ustb.mis.dm.Constants;
import edu.ustb.mis.dm.impl.algorithm.TextInputAndTextOutputCABOSFV;
import edu.ustb.mis.dm.interfaces.algorithm.ClusterAlgorithm;
import edu.ustb.mis.dm.model.ClusterResult;
import edu.ustb.mis.dm.util.Utils;

public class CABOSFVMain {
	public static void main(final String[] args) {
		int error = 0;
		for (int i = 0; i < 100; i++) {
			final ClusterAlgorithm<ClusterResult> cabosfv = new TextInputAndTextOutputCABOSFV(Constants.HOUSE_NAME);
			// cabosfv.setThreshhold(0.15);
			//cabosfv.setThreshhold(0.0444444);
			cabosfv.setThreshhold(0.29);
			cabosfv.execute();
			final List<ClusterResult> list = cabosfv.getResultList();
			boolean flag = true;
			for (final ClusterResult clusterResult : list) {
				final List<String> classIDList = clusterResult.getClassIDList();
				final Set<String> nameSet = new HashSet<String>();
				for (final String classID : classIDList) {
					//nameSet.add(classID.substring(classID.length() - 1));
					nameSet.add(classID.substring(0, 3));
				}
				if (nameSet.size() != 1) {
					flag = false;
					//System.out.println(classIDList);
					//System.out.print(i+",");
					error++;
					break;
				}
			}
			if (flag) {
				Utils.serialization(cabosfv.getResultList(), Constants.S_PATH);
			}
		}
		System.out.println("error=" + error);
	}
}
